﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections;
using System.Collections.ObjectModel;

namespace PersonaLibrary.View.EmploeeView
{
    /// <summary>
    /// Interaction logic for Emploees.xaml
    /// </summary>
    public partial class Emploees : UserControl
    {
        string keys = " АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";

        public Emploees()
        {
            InitializeComponent();       
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            emploeeKeyListBox.ItemsSource = keys.ToArray();
            emploeesList.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Surname", System.ComponentModel.ListSortDirection.Ascending));
        }

        private void emploeeKeyListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count != 0)
            {
                emploeesList.Items.Filter = delegate(object item)
                {
                    if (((Data.Employee)item).Surname.StartsWith(e.AddedItems[0].ToString())) return true;
                    else return false;
                };
            }
        }
    }
}
